<template>
  <div id="singer">
    <h3>歌手名称：{{ singerName }}</h3>
    <h3>所在地区：{{ place }}</h3>
    <button @click="sendSingerNameToMovie">把歌手名传递给电影组件</button>
    <hr />
  </div>
</template>

<script>
import pubsub from "pubsub-js";
export default {
  name: "Singer",
  data() {
    return {
      singerName: "成龙",
      place: "香港",
    };
  },
  methods: {
    sendSingerNameToMovie() {
      // 发布消息
      pubsub.publish("transmitName", this.singerName);
    },
  },
};
</script>

<style>
#singer {
  color: blue;
}
</style>